<?
class clscomform extends yellowpages{ 
	function sql(){
		$a = func_get_args();
		switch($a[0]){
			case "comform":
				$sql = "select com_form_id,com_form_name_$a[1]
						from com_form order by com_form_name_$a[2]";
				break;
			case "comform town":
				$sql = "SELECT town.town_id, town_name_%s FROM company,town 
						WHERE (company.town_id=town.town_id) and (com_form_id=%s)
						group by town_name_%s
						order by town_name_%s";
				$sql = sprintf($sql,$a[1],$a[3],$a[1],$a[2]);
				break;
			default:
				$sql = "select com_form_name_$a[1] from com_form WHERE com_form_id=$a[2]";// echo($sql);
		}	//Ew
		return $sql;
	}
 	//"comform", $lang, $ids, $lngs
	function showResult(){	//"comform town", $lang, $id, $lngs, $ids
		$a 		= func_get_args(); 
		$sql	= $this->sql($a[0], $a[1], $a[3], $a[2]);
		$result	= mysql_query($sql) or die("counld not query");
		$t='';
		if(!isset($_REQUEST['word'])) $_REQUEST['word']='';
		if($a[1]=='us')
			$langs='';
		else
			$langs="$a[1]";
		if($a[0]=='comform') 
			$lnk="comform_town$langs";
		else
			$lnk="puttype";
		
		while($rs=mysql_fetch_array($result,MYSQL_NUM)){
			if($a[0]=='comform town') 
				$lnks=$lnk.".php?ids=".$a[4]."&key=".$a[2]."&kind=comform&lang=".$a[1]."&tw=".$rs[0]."&word=".$_REQUEST['word'];
			else
				$lnks=$lnk.".php?ids=".$a[2]."&id=".$rs[0]."&word=".base64_encode($rs[1]);
			
			$t .= "<tr><td class=pdlr10 width=1px height=24><img src=images/muiten.gif></td>
			  <td width=380><a class=l_mid href=$lnks>$rs[1]</a></td></tr>";
		}	//Ew
		
		unset($rs);
		mysql_free_result($result); 
		
		$nn="";
		// echo($a[4]." a");
		//tri:&& !empty($a[4])
		if(isset($a[4])&& !empty($a[4])){ 
			echo("<table class=tab cellpadding=0 cellspacing=0>".$this->takeName($a[1], $a[2], '', "id='".$a[0]."'")."</td></tr>
				<tr><td><div class=menus><div id=ismenuss class=scr><table class=tab cellpadding=0 cellspacing=0>"); 
			$nn = "</table></div></div></td></tr>";
		}
		return $t.$nn;
	}
 
	function takeName($lang='us', $_id, $tp='', $gid=''){
		$sql = $this->sql($tp, $lang, $_id) ; 
		$result = mysql_query($sql) or die("Couldn't run query!takename");
		$rs = mysql_fetch_array($result);
		$t = "<tr><td $gid height=20 width=180 bgcolor=#1B90D5 class=font13 style='padding-left:5px' colspan=2>$rs[0]</td></tr>";
		//echo(htmlspecialchars($t));
		return $t;
	}
 
 
 function name(){//"comform town", $lang, $id, $lngs, $ids
  $a 		= func_get_args(); //print_r($a);
  $sql		= $this->sql($a[0], $a[1], $a[3], $a[2]);//  echo("$sql <br>");
  $result	= mysql_query($sql) or die("counld not query");
  $t='';
  if(!isset($_REQUEST['word'])) $_REQUEST['word']='';
  if($a[1]=='us')
   $langs='';
  else
   $langs="$a[1]";
  if($a[0]=='comform') 
   $lnk="comform_town$langs";
  else
   $lnk="puttype";
   
  while($rs=mysql_fetch_array($result,MYSQL_NUM)){
   if($a[0]=='comform town') 
    $lnks="$lnk.php?ids=$a[4]&key=$a[2]&kind=comform&lang=$a[1]&tw=$rs[0]&word=".$_REQUEST['word'];
   else
    $lnks="$lnk.php?ids=$a[2]&id=$rs[0]&word=".base64_encode($rs[1]);
	
   $t.="";
  }
  unset($rs);
  mysql_free_result($result); $nn="";// echo($a[4]." a");
  if(isset($a[4])){ 
   echo("<table class=tab cellpadding=0 cellspacing=0>".$this->takeName($a[1], $a[2], '', "id='".$a[0]."'")."</td></tr>
   		<tr><td><div class=menus><div id=ismenuss class=scr><table class=tab cellpadding=0 cellspacing=0>"); 
   $nn="</table></div></div></td></tr>";}
  return $t.$nn;
 }
 function show(){//"comform town", $lang, $id, $lngs, $ids
  $a 		= func_get_args(); //print_r($a);
  $sql		= $this->sql($a[0], $a[1], $a[3], $a[2]);//  echo("$sql <br>");
  $result	= mysql_query($sql) or die("counld not query");
  $t='';
  if(!isset($_REQUEST['word'])) $_REQUEST['word']='';
  if($a[1]=='us')
   $langs='';
  else
   $langs="$a[1]";
  if($a[0]=='comform') 
   $lnk="comform_town$langs";
  else
   $lnk="puttype";
   
  while($rs=mysql_fetch_array($result,MYSQL_NUM)){
   if($a[0]=='comform town') 
    $lnks="$lnk.php?ids=$a[4]&key=$a[2]&kind=comform&lang=$a[1]&tw=$rs[0]&word=".$_REQUEST['word'];
   else
    $lnks="$lnk.php?ids=$a[2]&id=$rs[0]&word=".base64_encode($rs[1]);
	
   $t.="<tr><td class=pdlr10 width=1px height=24><img src=images/muiten.gif></td>
      <td width=380><a class=l_mid href=$lnks>$rs[1]</a></td></tr>";
  }
  unset($rs);
  mysql_free_result($result); $nn="";// echo($a[4]." a");
  if(isset($a[4])){ 
   echo(""); 
   $nn="</table></div></div></td></tr>";}
  return $t.$nn;
 }
 
}//end class
?>